﻿using DryWCS.Model.Enum;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace DryWCS.App.Converter
{
    public class TaskTypeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string ret = null;
            if (value != null)
            {
                byte bvalue = 0;
                if (value.ToString() != "0")
                    bvalue = (byte)value;
                switch (bvalue)
                {
                    case (byte)TaskType.入库:
                        ret = "入库"; //盘点出库 盘点回库  货物移库
                        break;
                    case (byte)TaskType.出库:
                        ret = "出库";
                        break;
                    case (byte)TaskType.复位:
                        ret = "复位";
                        break;
                    default:
                        ret = "未知任务";
                        break;
                }

            }
            return ret;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            byte ret = 0;
            if (value != null)
            {
                string str = value.ToString();
                switch (str)
                {
                    //case "入库":
                    //    ret = (byte)TaskType.入库;
                    //    break;
                    //case "出库":
                    //    ret = (byte)TaskType.出库;
                    //    break;
                    //case "复位":
                    //    ret = (byte)TaskType.复位;
                    //    break;
                    //default:
                    //    ret = 0;
                    //    break;
                    case "入库":
                        ret = 2;
                        break;
                    case "出库":
                        ret = 3;
                        break;
                    case "复位":
                        ret = 1;
                        break;
                    default:
                        ret = 0;
                        break;
                }

            }
            return ret;
        }

       
    }
}
